<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>发表评价</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description"
          content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.">
    <link rel="stylesheet" th:href="@{/wxui/lib/weui.min.css}"/>
    <link rel="stylesheet" th:href="@{/wxui/css/jquery-weui.css}"/>
    <link rel="stylesheet" th:href="@{/wxui/css/style.css}"/>
</head>
<body ontouchstart>
<!--主体-->
<header class="wy-header">
    <div class="wy-header-icon-back"><span></span></div>
    <div class="wy-header-title">发表评价</div>
</header>
<div class="weui-content clear">
    <div class="order-list-Below clear">
        <h1>商品评价</h1>
        <ul id="start">
            <li class="on"></li>
            <li class="on"></li>
            <li class="on"></li>
            <li class="on"></li>
            <li class="on"></li>
        </ul>
    </div>
    <form id="commentForm">
        <div class="weui-cells weui-cells_form com-txt-area">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                <textarea class="weui-textarea txt-area" name="content" placeholder="这个商品满足你的期待吗？说说你的使用心得，分享给想买的他们吧"
                          rows="3"></textarea>
                    <input type="hidden" name="orderId" th:value="${orderId}" id="orderId"/>
                    <input type="hidden" name="level" value="5" id="level"/>
                    <input type="hidden" name="goodsId" th:value="${goodsId}" id="goodsId"/>
                    <input type="hidden" name="isShowName" value="1" id="isShowName"/>
                    <!-- <div class="weui-textarea-counter font-12 num"><span>0</span>/200</div> -->
                </div>
            </div>
        </div>
        <div class="weui-cells weui-cells_checkbox commg">
            <label class="weui-cell weui-check__label" for="s11">
                <div class="weui-cell__hd">
                    <input type="checkbox" class="weui-check" name="checkbox1" id="s11" checked="checked">

                    <i class="weui-icon-checked"></i>
                </div>
                <div class="weui-cell__bd"><p>匿名评价</p></div>
            </label>
        </div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <div class="weui-uploader">
                        <div class="weui-uploader__hd">
                            <p class="weui-uploader__title font-14">图片上传</p>
                            <div class="weui-uploader__info font-12">0/4</div>
                        </div>
                        <div class="weui-uploader__bd">
                            <ul class="weui-uploader__files" id="uploaderFiles">

                            </ul>
                            <div class="weui-uploader__input-box">
                                <input id="uploadimg" class="weui-uploader__input" name="file" type="file"></input>
                                <input type="hidden" name="img"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="com-button"><a href="javascript:void(0);" id="subBtn">发表评价</a></div>
    </form>
</div>
<script th:src="@{/wxui/lib/jquery-2.1.4.js}"></script>
<script th:src="@{/wxui/lib/fastclick.js}"></script>
<script th:src="@{/wxui/js/jquery-weui.js}"></script>
<script type="text/javascript" th:src="@{/wxui/js/jquery.Spinner.js}"></script>
<script type="text/javascript" th:src="@{/frame/layui/layui.js}"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
        $(".wy-header-icon-back").click(function () {
            window.history.back();
        });
    });
</script>
<script type="text/javascript">

    layui.use(['upload'], function () {
        var upload = layui.upload;
        var $ = layui.$;
        upload.render({
            elem: '#uploadimg' //绑定元素
            ,
            field: 'file'
            ,
            url: '/upload/simpleupload' //上传接口
            ,
            done: function (res) {
                if ($("#uploaderFiles li").length > 3) {
                    $.alert({
                        text: '图片上传已达上限'
                    });
                } else {
                    $("#uploaderFiles").append('<li class="weui-uploader__file"> <img class="upload-img" name="showimgs" src="' + res.data + '"></li>'),
                        $("#uploaderFiles").append('<input type="hidden" name="showimgs" value="' + res.data + '" />')
                    $(".weui-uploader__info ").html($("#uploaderFiles li").length + "/4")
                }
            },
            error: function () {
                //请求异常回调
            }
        });
    })


    $("#subBtn").click(function () {
        $("#level").val($("#start .on").length);
        $.ajax({
            url: "/orderInfo/frontStage/addComment",
            dataType: "json",
            data: $("#commentForm").serialize(),
            type: "post",
            success: function (data) {
                if (data.code == 200) {
                    $.toast(data.msg),
                        setTimeout('location.href="/orderInfo/frontStage/lookOrders?state="', 1000)
                } else {
                    alert(data.msg);
                    $.toast(data.msg)
                }
            }
        })
    })

    $("#s11").click(function () {
        if ($("#isShowName").val() == 1) {
            $("#isShowName").val(0)
        } else {
            $("#isShowName").val(1)
        }
    })


    $(".order-list-Below ul li").click(
        function () {
            var num = $(this).index() + 1;
            var len = $(this).index();
            var thats = $(this).parent(".order-list-Below ul").find("li");
            if ($(thats).eq(len).attr("class") == "on") {
                if ($(thats).eq(num).attr("class") == "on") {
                    $(thats).removeClass();
                    for (var i = 0; i < num; i++) {
                        $(thats).eq(i).addClass("on");
                    }
                } else {
                    $(thats).removeClass();
                    for (var k = 0; k < len; k++) {
                        $(thats).eq(k).addClass("on");
                    }
                }
            } else {
                $(thats).removeClass();
                for (var j = 0; j < num; j++) {
                    $(thats).eq(j).addClass("on");
                }
            }
        }
    );
</script>

</body>
</html>
